package com.hzdl.car.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hzdl.car.bean.Car;
import com.hzdl.car.bean.Customer;
import com.hzdl.car.mapper.CarMapper;
import com.hzdl.car.service.CarService;
import com.hzdl.car.vo.CarVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CarServiceimpl implements CarService {
    @Autowired
    private CarMapper mapper;
    @Override
    public PageInfo<Car> findWhere(CarVo carVo) {

        PageHelper.startPage(carVo.getPage(),carVo.getLimit());
        List<Car> list = mapper.findWhere(carVo);
        return new PageInfo<>(list);
    }

    @Override
    public int add(CarVo carVo) {
        return mapper.add(carVo);
    }

    @Override
    public int update(CarVo carVo) {
        return mapper.update(carVo);
    }

    @Override
    public int delete(String carnumber) {
        return mapper.delete(carnumber);
    }

    @Override
    public Customer findById(String identity) {
        return mapper.findById(identity);
    }

    @Override
    public PageInfo<Car> findByisrenting(CarVo carVo) {
        PageHelper.startPage(carVo.getPage(),carVo.getLimit());
        List<Car> list = mapper.findByisrenting(carVo);
        return new PageInfo<>(list);

    }

    @Override
    public int isrentingupdate(CarVo carVo) {
        return mapper.isrentingupdate(carVo);
    }


}
